#if UNITY_EDITOR
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Batch2D;
using CSUtils;
using Spine2;
using U3dUtils;
using U3dUtilsEditor;
using UnityEditor;
using UnityEngine;

namespace Spine2 {
    public class Editor_SpineFileFix {
        const string _tag = "Editor_SpineFileFix";

        //[MenuItem("Assets/Spine工具/删除meta,从新生成", false, 180)]
        static void Start() {
            CLogCat.GetInstance().Init(true, true);
            var dirArr = Selection.assetGUIDs;
            for (int i3 = 0; i3 < dirArr.Length; i3++) {
                var dir = AssetDatabase.GUIDToAssetPath(dirArr[i3]);
                if (Directory.Exists(dir) == false) {
                    dir = Path.GetDirectoryName(dir);
                    if (Directory.Exists(dir) == false) {
                        continue;
                    }
                }
                var str0Len = ".atlas.txt".Length;
                var fileArr = Directory.GetFiles(dir, "*.atlas.txt", SearchOption.AllDirectories);
                for (int i5 = 0; i5 < fileArr.Length; i5++) {
                    var atlasPath = fileArr[i5];
                    if (atlasPath.EndsWith(".meta", StringComparison.Ordinal)) {
                        continue;
                    }
                    var path0 = atlasPath.Substring(0, atlasPath.Length - str0Len);
                    var path2 = $"{path0}_SkeletonData.asset";
                    if (File.Exists(path2) == false) {
                        CFile.DeleteFile(atlasPath + ".meta");
                        CFile.DeleteFile(path0 + ".json.meta");
                    }
                }
            }

            AssetDatabase.Refresh();
        }
    }
}

#endif
